Skip to content

Conversation

last-genius
Copy link
Contributor

Cross-pool migrations set scheduled_to_be_resident_on to the destination host, reserving memory and vGPUs. If the VM is still halted when migration is finished, the field is not cleared on the destination, preserving the reservations even though they're not necessarily going to be used anytime soon.

Call force_state_reset_keep_current_operations in pool_migrate_complete on the destination to clear the reservations among other things at the end of the migration.

This fixes an issue when VMs migrated across pools in a halted state would take up memory in xapi's view (but not in RRD's view), which is not intuitive and could prevent further migrations from claiming enough free memory on the host.


I've tested this manually, confirming that migrating halted and running VMs works as designed, with the scheduled_to_be_resident_on field cleared at the end of the migration (in the first case it's because of the fix, in the second one it's because the VM is actually started on the host)

Cross-pool migrations set scheduled_to_be_resident_on to the destination host,
reserving memory and vGPUs. If the VM is still halted when migration is
finished, the field is not cleared on the destination, preserving the
reservations even though they're not necessarily going to be used anytime soon.

Call force_state_reset_keep_current_operations in pool_migrate_complete on the
destination to clear the reservations among other things at the end of the
migration.

This fixes an issue when VMs migrated across pools in a halted state would take
up memory in xapi's view (but not in RRD's view), which is not intuitive and
could prevent further migrations from claiming enough free memory on the host.

Signed-off-by: Andrii Sultanov <[email protected]>
Copy link
Member

@robhoes robhoes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is safe. The function Xapi_vm_lifecycle.force_state_reset_keep_current_operations looks a little scary to call on running VMs, but it takes the power state into account. In fact, it is already called for running VMs in update_vm inside xapi_xenops.ml.

@last-genius last-genius added this pull request to the merge queue Sep 5, 2025
Merged via the queue into xapi-project:master with commit 8b43206 Sep 5, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants